import web

from process import Process

urls = ('/', 'Index',
        '/search', 'Search',
        '/(\d+)', 'Document')
app = web.application(urls, globals())
web.config.debug = True

class Index:
    def __init__(self):
        self.render = web.template.render("templates/")
        
    def GET(self, name=None):
        if name == "Hello":
            return "Hello World"
        return self.render.index()
    
class Search:
    def GET(self):
        searchString = web.input().query
        processString = Process()
        return processString.run(searchString)

class Document:
    def __init__(self):
        self.render = web.template.render("templates/")
        
    def GET(self, docID):
        processor = Process()
        text = processor.getDoc(docID)
        return self.render.document(text)

if __name__ == '__main__':app.run()